<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('数据查询列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                收费站：
                                <select name="stationHex">
                                    <option value="">请选择收费站</option>
                                    <option th:each="station : ${stations}" th:value="${station.stationHex}" th:text="${station.stationHex + ' -- ' + station.stationName}"></option>
                                </select>
                            </li>
                            <li>
                                <label>车道：</label>
                                <select name="laneId">
                                    <option value="">请选择具体车道</option>
                                </select>
                            </li>
                            <li>
                                车道类型：
                                <select name="laneType" th:with="type=${@dict.getType('sys_lane_type')}">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>识别车牌：</label>
                                <input type="text" name="vprVehicleId"/>
                            </li>
                            <li>
                                特情类型
                                <select name="applyType">
                                    <option value="">请选择特情类型</option>
                                    <option th:each="type : ${applyTypes}" th:value="${type.dataCode}" th:text="${type.dataCode + ' -- ' + type.dataValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>申请时间： </label>
                                <input type="text" class="time-input" id="applyTime" name="params[applyTime]" placeholder="申请时间"/>
                            </li>
                            <li>
                                <label>数据编号：</label>
                                <input type="text" name="tradeId"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:laneapply:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:laneapply:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:laneapply:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:laneapply:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
                <div class="record">
                    <p>查询到<span id="totalCount">0</span>条数据；实际特情车<span id="teQingCount">0</span>辆，坐席远程处理<span id="seatProcessTotal">0</span>辆，坐席处理比例<span id="seatProcessRatio">0%</span></p>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">

        var editFlag = [[${@permission.hasPermi('system:laneapply:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:laneapply:remove')}]];
        var prefix = ctx + "system/laneapply";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                // modalName: "数据查询",
                // sortName: "applyTime",
                sortOrder: "desc",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'tradeId',
                    title: '数据编号',
                    visible: true,
                    // width: 10
                },
                {
                    field: 'stationName',
                    title: '收费站'
                },
                {
                    field: 'seatId',
                    title: '坐席编号'
                },
                {
                    field: 'userId',
                    title: '坐席人员'
                },
                {
                    field: 'applyTime',
                    title: '申请时间',
                    // sortable: true
                },
                {
                    field: 'laneId',
                    title: '车 道'
                },
                {
                    field: 'vprVehicleId',
                    title: '识别车牌'
                },
                {
                    field: 'applyTypeName',
                    title: '特情名称'
                },
                {
                    field: 'dealState',
                    title: '处理状态',
                    // align: 'center',
                    formatter: function(value, row, index) {
                        if (value == 1) {
                            return '<span class="badge badge-primary">已处理</span>';
                        } else if (value == 2) {
                            return '<span class="badge badge-success">已转接</span>';
                        } else {
                            return '<span class="badge badge-danger">待处理</span>';
                        }
                    }
                },
                {
                    field: 'processingMethod',
                    title: '处理方式',
                    // sortable: true,
                    formatter: function(value, row, index) {
                        if (value == "现场处理") {
                            return '<span class="badge badge-danger">现场处理</span>';
                        } else if (value == "坐席远控") {
                            return '<span class="badge badge-primary">坐席远控</span>';
                        } else if (value == "自动处理") {
                            return '<span class="badge badge-success">自动处理</span>';
                        } else if (value == "坐席转接") {
                            return '<span class="badge badge-info">坐席转接</span>';
                        } else if (value == "可视对讲") {
                            return '<span class="badge badge-warning">可视对讲</span>';
                        } else if (value == "坐席识别") {
                            return '<span class="badge badge-default">坐席识别</span>';
                        }
                    }
                }
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.tradeId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tradeId + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                // }
                ],
                responseHandler: function(res) {
                    // 更新统计数据
                    if (res.stats) {
                        $("#totalCount").text(res.stats.totalCount || 0);
                        $("#teQingCount").text(res.stats.teQingCount || 0);
                        $("#seatProcessTotal").text(res.stats.seatProcessTotal || 0);
                        $("#seatProcessRatio").text((res.stats.seatProcessRatio || 0) + '%');
                    }
                    return res;  // 返回原始数据供表格使用
                }
            };
            $.table.init(options);
        });

        $("select[name='stationHex']").change(function() {
            var stationHex = $(this).val();
            var laneSelect = $("select[name='laneId']");

            // 清空现有选项
            laneSelect.empty().append('<option value="">请选择具体车道</option>');

            if (stationHex) {
                $.ajax({
                    url: ctx + "system/laneapply/getLanesByStation",
                    type: "GET",
                    data: { stationHex: stationHex },
                    dataType: "json",
                    success: function(data) {
                        $.each(data, function(index, lane) {
                            laneSelect.append($('<option>', {
                                value: lane.laneId,
                                text: lane.laneName || lane.laneId
                            }));
                        });
                    },
                    error: function() {
                        $.modal.alertError("加载车道数据失败");
                    }
                });
            }
        });
    </script>
</body>
</html>